package com.cq.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cq.entity.Dept;
import com.cq.service.DeptService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * @author C-Q
 * @version 1.1.0
 * @Description: TODO
 * @date 2022/11/15
 * 查询操作Get 添加操作Post 修改操作Put 删除操作Delete
 */
@RestController
@RequestMapping("/api")
@Api(tags = "测试swagger的api接口类")//修饰整个类，描述controller的作用
public class TestController {
    @GetMapping("/tes")
    public Map<String,Object> tes(){
        Map<String, Object> map=new HashMap<>();
        map.put("张三",18);
        map.put("list",25);
        return map;
    }
        //查询加分页
        @Resource
        private DeptService deptService;
        @GetMapping("list")
        @ApiOperation("根据Id查询信息")
        public Page<Dept> list(Integer current, Integer pageSize){
            return deptService.findByPage(current,pageSize);
        }

        //删除
        @RequestMapping("dele")
        @ApiOperation("根据Id删除对应行")
        public int dele(int DEPTNO){
            System.out.println(DEPTNO);
            return deptService.delete(DEPTNO);
        }

        //修改
        @PostMapping("update")
        @ApiOperation("根据部门对象修改信息")
        public int update(@RequestBody Dept dept){
            return deptService.updateSer(dept);
        }

        //添加
        @PostMapping("inserts")
        @ApiOperation("根据部门对象添加信息")
        public int inserts(@RequestBody Dept dept){
            return deptService.insertDept(dept);
        }

        //swagger测试
        @GetMapping("swaggerTest")
        @ApiOperation(value ="测试swagger第一个接口" )
        public String swaggerTest(){
            return "swaggerTest";
        }
        @PostMapping("getId")
        @ApiOperation("根据Id查询信息")
        @ApiImplicitParams({
                @ApiImplicitParam(name = "id" ,defaultValue = "1",required = true,value = "编号",dataType = "int"),
                @ApiImplicitParam(name = "name" ,defaultValue = "ZY",required = false,value = "姓名",dataType = "string")
        })
        public String getId(Integer a){
            return "根据Id查询数据";
        }
}




















































